package com.jiangyg.mall.order.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.order.dao.OrderOperateHistoryDao;
import com.jiangyg.mall.order.dto.OrderOperateHistoryDTO;
import com.jiangyg.mall.order.entity.OrderOperateHistory;
import com.jiangyg.mall.order.vo.OrderOperateHistoryVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderOperateHistoryServiceImpl extends BaseServiceImpl<OrderOperateHistoryDao, OrderOperateHistory> implements OrderOperateHistoryService {

    @Autowired
    public OrderOperateHistoryServiceImpl(OrderOperateHistoryDao orderOperateHistoryDao) {
        super(orderOperateHistoryDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<OrderOperateHistoryVO> selectPagination(Pagination<OrderOperateHistoryVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, OrderOperateHistoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(OrderOperateHistoryDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public OrderOperateHistoryVO selectById(Long orderOperateHistoryId) throws Exception {
        return this.executeSelectById(orderOperateHistoryId, OrderOperateHistoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> orderOperateHistoryIds) {
        return this.baseMapper.deleteBatchIds(orderOperateHistoryIds) > 0;
    }

}
